package ywpt.service.system;

import java.util.List;

import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProxy;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import ywpt.model.Form;
import ywpt.model.PeopleInfo;
import ywpt.core.dao.extend.HibernateEntityExtendDao;
import ywpt.core.exception.UniqueConstraintException;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;
@Service("formService")
@RemoteProxy(name="formService")
public class FormServiceImpl extends HibernateEntityExtendDao<Form> implements
		FormService {

	public FormServiceImpl() {
	}

	/* ���� Javadoc��
	 * @see ywpt.service.system.FormService#getFormById(java.lang.Long)
	 */
	public Form getFormById(Long id) {
		// TODO �Զ���ɷ������
		return this.get(id);
	}

	/* ���� Javadoc��
	 * @see ywpt.service.system.FormService#getFormLibs(org.hibernate.criterion.DetachedCriteria)
	 */
	public List<Form> getFormLibs(DetachedCriteria query) {
		// TODO �Զ���ɷ������
		return this.findAllByCriteria(query);
	}

	/* ���� Javadoc��
	 * @see ywpt.service.system.FormService#getForms(org.hibernate.criterion.DetachedCriteria, int, int)
	 */
	public List<Form> getForms(DetachedCriteria query, int pageSize, int startIndex) {
		// TODO �Զ���ɷ������
		return this.findAllByCriteria(query, pageSize, startIndex);
	}

	/* ���� Javadoc��
	 * @see ywpt.service.system.FormService#getKnowLibCountByCriteria(org.hibernate.criterion.DetachedCriteria)
	 */
	public int getKnowLibCountByCriteria(DetachedCriteria query) {
		// TODO �Զ���ɷ������
		return this.getCountByCriteria(query);
	}

	/* ���� Javadoc��
	 * @see ywpt.service.system.FormService#removeupdatForm(java.lang.Long)
	 */
	public void removeForm(Long id) {
		// TODO �Զ���ɷ������
		System.out.println("removeForm"+id);
		super.removeById(id);
	}
	public int[] removeForms(Long[] ids) {
		String hql = "delete ywpt.model.Form u where u.id =?";
		int results[] = new int[ids.length];
		for (int i = 0; i < ids.length; i++) {
			results[i] = super.bulkUpdate(hql, ids[i]);
		}
		return results;
	}

	/* ���� Javadoc��
	 * @see ywpt.service.system.FormService#saveForm(ywpt.model.Form, java.lang.Long)
	 */
	public void saveForm(Form form) {
		// TODO �Զ���ɷ������

		super.save(form);		
	}

	/* ���� Javadoc��
	 * @see ywpt.service.system.FormService#updatForm(ywpt.model.Form, java.lang.Long)
	 */
	public void updatForm(Form form) {
		// TODO �Զ���ɷ������
		super.update(form);
	}

	public List<Form> getAllForms() {
		// TODO �Զ���ɷ������
		return this.getAll();
	}
	@RemoteMethod
	public boolean checkformItem(String value, String name) {
		// TODO �Զ���ɷ������
		DetachedCriteria query = DetachedCriteria.forClass(Form.class);
		query.add(Restrictions.eq(name, value));
		int i =this.getCountByCriteria(query);
		if(i>0)//�ظ�
		{
			return true;
		}else
		{
			return false;
		}
	}


}
